// MessageBoxFilter.h: interface for the CMessageBoxFilter class.
//
//////////////////////////////////////////////////////////////////////
/********************************************************************
	created:	2012/05/02
	created:	2:5:2012   16:36
	file base:	MessageBoxFilter
	file ext:	h
	author:		wuxiangfei
*********************************************************************/
#if !defined(AFX_MessageBoxFilter_H__872EF3D7_54AB_41C3_B49C_10F45D80F773__INCLUDED_)
#define AFX_MessageBoxFilter_H__872EF3D7_54AB_41C3_B49C_10F45D80F773__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

typedef int (__stdcall * MYMESSAGEBOXA)(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType);
typedef int (__stdcall * MYMESSAGEBOXW)(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType);

class CMessageBoxFilter  
{
private:
	CMessageBoxFilter();

public:
	static CMessageBoxFilter *CreatInstance(void);
	virtual ~CMessageBoxFilter();

	void SetEnable(BOOL bEnable=TRUE);
	void SetCaptionFilter(CString strSubstring);
	void SetTextFilter(CString strSubstring);

private:
	static void HookFun(void *TargProc, void *NewProc, void **l_OldProc, int nByteScopy=5);
	static void UnHookFun(void *TartProc, void *l_SavedFun, UINT Len=5);

	static int __stdcall MyMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType);
	static int __stdcall MyMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType);

private:
	static UINT *m_OldMessageBoxA;
	static UINT *m_OldMessageBoxW;
	static BOOL m_bEnable;
	static CString m_strCaptionFilter;
	static CString m_strTextFilter;
	static CMessageBoxFilter *m_pMessageBoxFilter;


};

#endif // !defined(AFX_MessageBoxFilter_H__872EF3D7_54AB_41C3_B49C_10F45D80F773__INCLUDED_)
